<template>
  <div class="fixed top-0 left-0 w-screen h-screen text-xl z-20 backdrop-blur-4xl bg-white dark:bg-zinc-800 pb-2 overflow-y-auto xl:p-2 xl:bg-transparent">
    <!-- 移动端下的 navbar -->
    <m-navbar v-if="isMobileTerminal">
      {{ rowData.title }}
      <template #right>
        <m-svg-icon
          name="share"
          class="w-3 h-3"
          fillClass="fill-zinc-900 dark:fill-zinc-200"
        />
      </template>
    </m-navbar>
    <!-- PC 端 -->
    <m-svg-icon
      v-else
      name="close"
      class="w-3 h-3 ml-1 p-0.5 cursor-pointer duration-200 rounded-sm hover:bg-zinc-100 absolute
      right-2 top-2"
      fillClass="fill-zinc-400"
      @click="onClose"
    />
    <!-- 内容区 -->
    <div v-if="rowData.photo" class="xl:w-[80%] xl:h-full xl:mx-auto xl:rounded-lg xl:flex">
      <img
        class="w-screen mb-2 xl:w-3/5 xl:h-full xl:rounded-tl-lg xl:rounded-bl-lg"
        :src="rowData.photo"
      />
      <div class="xl:w-2/5 xl:h-full xl:bg-white xl:dark:bg-zinc-900 xl:rounded-tr-lg xl:rounded-tb-lg xl:p-3">
        <!-- PC下：收藏、分享 -->
        <div
          v-if="!isMobileTerminal"
          class="flex justify-between mb-2"
        >
          <!-- 分享 -->
          <m-svg-icon
            name="share"
            class="w-4 h-4 p-1 cursor-pointer hover:bg-zinc-200 dark:hover:bg-zinc-800 duration-300 rounded"
            fillClass="fill-zinc-900 dark:fill-zinc-200"
          />
          <!-- 收藏 -->
          <m-button
            type="info"
            icon="heart"
            iconClass="fill-zinc-900 dark:fill-zinc-200"
          />
        </div>
        <!-- 标题 -->
        <p class="text-base text-zinc-900 dark:text-zinc-200 ml-1 font-bold xl:text-xl xl:mb-5">
          {{ rowData.title }}
        </p>
        <!-- 作者 -->
        <div class="flex items-center mt-1 px-1">
          <img
            v-lazy
            class="h-3 w-3 rounded-full"
            :src="rowData.avatar"
          />
          <span class="text-base text-zinc-900 dark:text-zinc-200 ml-1">
            {{ rowData.author }}
          </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { isMobileTerminal } from '@/utils/flexible'
import { useRouter } from 'vue-router'

const router = useRouter()

defineProps({
  id: {
    type: String,
    required: true
  },
  rowData: {
    type: Object,
    default: () => {}
  }
})

/**
 * 关闭
 */
const onClose = () => {
  router.back()
}
</script>

<style lang="scss" scoped></style>
